#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2018/3/13 15:04
# @Author  : Swper
# @Site    : 
# @File    : config.py
# @Software: PyCharm
import os
import sqlite3
basedir = os.path.abspath(os.path.dirname(__file__))

class Config():
    #session key
    SECRET_KEY = os.urandom(24)
    SQLALCHEMY_TRACK_MODIFICATIONS = False

#定义多个数据库环境连接信息
class DevelopmentConfig(Config):
    DEBUG=True
    DATABASE = 'cmdbtest'
    DB_URI = 'mysql+pymysql://dba:123456@10.0.10.110:3306/{}?charset=utf8'.format(DATABASE)
    SQLALCHEMY_DATABASE_URI = DB_URI

class ProductionConfig(Config):
    DATABASE = 'demo916'
    DB_URI = 'mysql+pymysql://username:passwd@host:port/{}?charset=utf8'.format(DATABASE)
    SQLALCHEMY_DATABASE_URI = DB_URI

class TestingConfig(Config):
    DEBUG=True
    # 建立一个sqlite数据文件保存在当前目录下的data.sqlite
    SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(basedir, 'data.sqlite')


config = {
    'dev':DevelopmentConfig,
    'pro':ProductionConfig,
    'test':TestingConfig,
    'default':DevelopmentConfig
}